package jsyf.oa.web.system;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.FastJsonConvert;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.system.Role2RightFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Lenovo on 2017/12/11.
 */
@Api(value = "岗位-权限接口", description = "岗位-权限接口")
@Controller
@RequestMapping("/role2Right")
public class Role2RightController {
    @Autowired
    private Role2RightFacade role2RightFacade;

    @RequestMapping(value = "/getByRoleId.json", method = RequestMethod.POST)
    public void getByRoleId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonParam = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> result = role2RightFacade.getByRoleId(jsonParam.getString("roleId"));
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }
}
